<?php defined('SYSPATH') OR die('No direct access allowed.');
class Signup_Controller extends Base_Controller {
	
	// Set the name of the template to use
	public $template = 'templates/base';
        
	public function index() {		
		// Create view
		$view = new View('/user/users_signup');

		$interest = new Interest_Model();
		$interestquestions = $interest->get_all_questions();
		$view->interestquestions = $interestquestions;

		$this->template->content = $view;
		$this->template->title = 'User Signup';
        }
        
        public function save() {
		
		if($this->input->post()) {
			// setup and initialize your form field names
			$form = array
			(
			    'name'      => '',
			    'number'    => '',
			    'password'  => '',
			    'code'      => '',
			);
		     
			//  copy the form as errors, so the errors will be stored with keys corresponding to the form field names
			$errors = $form;
			
			$post = new Validation($this->input->post());
		
			if($post->validate) {
				$user = new User_Model();	
			}
			else {
				$form = arr::overwrite($form, $post->as_array());
			        $errors = arr::overwrite($errors, $post->errors('form_error_messages'));
			}
		}
        }
        
        public function checkemail() {
		$user = new User_Model();
		$userdata = $user->get_user_by_email($_POST['email']); 
		
		if (request::is_ajax()) {
			echo json_encode($userdata);
		}            
        }
}

?>